﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Entities;

namespace Mapping
{
    public class TeacherMap : ClassMap<Teacher>
    {
        public TeacherMap()
        {
            Id(x => x.Id).GeneratedBy.Identity();
            Map(x => x.Family).Not.Nullable();
            Map(x => x.Name).Not.Nullable();
            Map(x => x.Patronymic).Not.Nullable();
            Map(x => x.Degree).Not.Nullable();
            Map(x => x.AcademicTitle);
            References(x => x.Department)
                .Column("DepartmentId")
                .ForeignKey()
                .Nullable()
                .Cascade.SaveUpdate();
            HasMany(x => x.LoadAtoms)
                .Cascade.SaveUpdate()
                .KeyColumn("TeacherId")
                .Inverse();
        }
    }
}
